package com.bkindex.kiducate.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bkindex.kiducate.R;
import com.bkindex.kiducate.views.GridGradeItem;

public class GridItemAdapter extends BaseAdapter{
	private ArrayList arrLImages;
	private LayoutInflater layoutInflater;
	public GridItemAdapter(Context iContext, ArrayList iArrL)
	{
		this.arrLImages = iArrL;
		layoutInflater = LayoutInflater.from(iContext);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return arrLImages.size();
	}
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return arrLImages.get(position);
	}
	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ImgHolder holder;
        if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.grade_item, null);
            holder = new ImgHolder();
            holder.imgView = (ImageView) convertView.findViewById(R.id.imgGradeItem);
            convertView.setTag(holder);
        } else {
            holder = (ImgHolder) convertView.getTag();
        }
        holder.imgView.setBackgroundDrawable(((GridGradeItem)arrLImages.get(position)).getMDrawable());
        return convertView;
	}
	static class ImgHolder
	{
		ImageView imgView;
	}
}